<template>
  <div class="wrapper">
    <div class="top" @click="goBack">
      <img src="@/assets/images/goBackImg.png" class="back" alt="header" />
    </div>
    <div class="main">
      <div class="header">
        <img src="@/assets/images/robot.png" alt="back" class="robot-icon" />
        <div class="header-title">
          <span class="title-text">我是您的AI教育顾问！</span>
          <span class="title-desc" v-typewriter="{ speed: 60, cursor: true }"
            >请选择您的选科起点和目标产业，我将根据您的信息，为您智能导航</span
          >
        </div>
      </div>
      <div class="component-wrapper">
        <keep-alive>
          <component
            :is="currentComponent"
            @goNext="goNext"
            @goLast="goLast"
          ></component>
        </keep-alive>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, computed, ref, shallowRef } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { useVolunteerStore } from '@/store/volunteer';
import { onBackPressed } from '@/utils/androidFn.js';
import FirstStep from './components/FirstStep.vue';
import SecondStep from './components/SecondStep.vue';

const route = useRoute();
const router = useRouter();
const store = useVolunteerStore();

const currentComponent = shallowRef(FirstStep);

const goNext = () => {
  currentComponent.value = SecondStep;
};

const goLast = () => {
  currentComponent.value = FirstStep;
};

const goBack = () => {
  if (route.query?.fromType == 'android') {
    onBackPressed(router);
  } else {
    router.go(-1);
  }
};

onMounted(() => {});
</script>

<style scoped lang="scss">
.wrapper {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: url('@/assets/images/homeBg.png') no-repeat center center;
  background-size: 100% 100%;
  .top {
    position: absolute;
    padding: 28px 30px 28px 30px;
    .back {
      width: 40px;
      height: 40px;
    }
  }
  .main {
    padding-top: 100px;
    display: flex;
    flex-direction: column;
    .header {
      width: 43vw;
      margin: 0 auto;
      display: flex;
      .robot-icon {
        width: 136px;
        height: 120px;
        margin-right: 18px;
      }
      .header-title {
        display: flex;
        flex-direction: column;
        .title-text {
          font-weight: bold;
          font-size: 44px;
          color: #000000;
          line-height: 67px;
          margin-bottom: 20px;
          white-space: nowrap;
        }
        .title-desc {
          font-weight: 400;
          font-size: 24px;
          color: #555555;
          line-height: 33px;
          white-space: nowrap;
        }
      }
    }
    .component-wrapper {
      margin-top: 52px;
    }
  }
}
</style>
